package com.panfeng.xcloud.boss.provider.assets.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.panfeng.xcloud.boss.provider.assets.dto.request.QueryOffsetTransFlowPageReqDTO;
import com.panfeng.xcloud.boss.provider.assets.dto.response.QueryOffsetTransFlowPageRespDTO;
import com.panfeng.xcloud.boss.provider.assets.service.IOffsetTransFlowService;
import com.panfeng.xcloud.boss.provider.assets.web.vo.request.QueryOffsetTransFlowPageReqVO;
import com.panfeng.xcloud.boss.provider.assets.web.vo.response.QueryOffsetTransFlowPageRespVO;
import com.panfeng.xcloud.common.core.page.PageResponse;
import com.panfeng.xcloud.common.core.utils.ConvertUtils;
import com.panfeng.xcloud.common.core.web.vo.PageResponseVO;
import com.panfeng.xcloud.common.core.web.vo.ResponseVO;
import com.panfeng.xcloud.common.security.annotation.MethodValidate;
import com.panfeng.xcloud.common.security.annotation.NotNeedAccess;
import com.panfeng.xcloud.common.security.web.support.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 对冲记录模块
 *
 * @author xiaobo
 * @version 1.0
 * @since 2021-03-24
 */
//@ApiIgnore
@RestController
@RequestMapping("assets/offsetTransFlow")
@Api(tags = {"对冲记录模块"})
@Slf4j
public class OffsetTransFlowController extends BaseController {

    @Autowired
    private IOffsetTransFlowService iOffsetTransFlowService;

    /**
     * 查询对冲交易记录
     *
     * @param queryOffsetTransFlowPageReqVO
     * @param bindingResult
     * @return
     */
    @NotNeedAccess
    @MethodValidate
    @PostMapping(value = "/queryOffsetTransFlow", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询对冲交易记录(肖博)", httpMethod = "POST", notes = "查询对冲交易记录(肖博)")
    public ResponseVO<PageResponseVO<QueryOffsetTransFlowPageRespVO>> queryOffsetTransFlow(@RequestBody @Valid QueryOffsetTransFlowPageReqVO queryOffsetTransFlowPageReqVO, BindingResult bindingResult) {
        logger.info(">>>> 当前queryOffsetTransFlow请求参数：{} <<<", (null != queryOffsetTransFlowPageReqVO ? JSONObject.toJSONString(queryOffsetTransFlowPageReqVO) : ""));
        QueryOffsetTransFlowPageReqDTO queryOffsetTransFlowPageReqDTO = ConvertUtils.convert(queryOffsetTransFlowPageReqVO, QueryOffsetTransFlowPageReqDTO.class);
        PageResponse<QueryOffsetTransFlowPageRespDTO> pageDTO = iOffsetTransFlowService.queryOffsetTransFlow(queryOffsetTransFlowPageReqDTO);
        PageResponseVO<QueryOffsetTransFlowPageRespVO> pageVO = ConvertUtils.convertPage(pageDTO, QueryOffsetTransFlowPageRespVO.class);
        logger.info(">>>> 当前queryOffsetTransFlow响应内容：{} <<<", (null != pageVO ? JSONObject.toJSONString(pageVO) : ""));
        return ResponseVO.with(pageVO);
    }

}
